import React, { useRef } from 'react';

const UseRef = () => {
  const inputRef = useRef(null);
  // 渲染完后才可使用
  const getDom = () => {
    console.log(inputRef.current);
  }
  return (
    <div>
      <input type="text" ref={inputRef} />
      <button onClick={getDom}>获取dom</button>
    </div>
  );
};

export default UseRef;